"""opti models

Revision ID: 994fef9106c3
Revises: 3a2c657e394c
Create Date: 2025-06-06 15:34:30.848157

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = '994fef9106c3'
down_revision: Union[str, None] = '3a2c657e394c'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    """Upgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_index('idx_audit_logs_action_created_at', 'audit_logs', ['action', 'created_at'], unique=False)
    op.create_index('idx_audit_logs_created_at', 'audit_logs', ['created_at'], unique=False)
    op.create_index('idx_audit_logs_ip_address', 'audit_logs', ['ip_address'], unique=False)
    op.create_index('idx_audit_logs_is_deleted', 'audit_logs', ['is_deleted'], unique=False)
    op.create_index('idx_audit_logs_resource_resource_id', 'audit_logs', ['resource', 'resource_id'], unique=False)
    op.create_index('idx_audit_logs_status_created_at', 'audit_logs', ['status', 'created_at'], unique=False)
    op.create_index('idx_audit_logs_user_id_created_at', 'audit_logs', ['user_id', 'created_at'], unique=False)
    op.create_index(op.f('ix_audit_logs_action'), 'audit_logs', ['action'], unique=False)
    op.create_index(op.f('ix_audit_logs_is_deleted'), 'audit_logs', ['is_deleted'], unique=False)
    op.create_index(op.f('ix_audit_logs_resource'), 'audit_logs', ['resource'], unique=False)
    op.create_index(op.f('ix_audit_logs_status'), 'audit_logs', ['status'], unique=False)
    op.create_index(op.f('ix_audit_logs_user_id'), 'audit_logs', ['user_id'], unique=False)
    op.create_index('idx_permissions_is_deleted_code', 'permissions', ['is_deleted', 'code'], unique=False)
    op.create_index('idx_permissions_is_deleted_name', 'permissions', ['is_deleted', 'name'], unique=False)
    op.create_index('idx_permissions_resource', 'permissions', ['resource'], unique=False)
    op.create_index('idx_permissions_resource_action', 'permissions', ['resource', 'action'], unique=False)
    op.create_index(op.f('ix_permissions_action'), 'permissions', ['action'], unique=False)
    op.create_index(op.f('ix_permissions_is_deleted'), 'permissions', ['is_deleted'], unique=False)
    op.create_index(op.f('ix_permissions_resource'), 'permissions', ['resource'], unique=False)
    op.create_index('idx_role_permissions_permission_id', 'role_permissions', ['permission_id'], unique=False)
    op.create_index('idx_role_permissions_role_id', 'role_permissions', ['role_id'], unique=False)
    op.create_index('idx_roles_is_deleted_is_active', 'roles', ['is_deleted', 'is_active'], unique=False)
    op.create_index('idx_roles_is_deleted_name', 'roles', ['is_deleted', 'name'], unique=False)
    op.create_index(op.f('ix_roles_is_active'), 'roles', ['is_active'], unique=False)
    op.create_index(op.f('ix_roles_is_deleted'), 'roles', ['is_deleted'], unique=False)
    op.create_index('idx_user_roles_role_id', 'user_roles', ['role_id'], unique=False)
    op.create_index('idx_user_roles_user_id', 'user_roles', ['user_id'], unique=False)
    op.create_index('idx_users_is_deleted_email', 'users', ['is_deleted', 'email'], unique=False)
    op.create_index('idx_users_is_deleted_is_active', 'users', ['is_deleted', 'is_active'], unique=False)
    op.create_index('idx_users_is_deleted_username', 'users', ['is_deleted', 'username'], unique=False)
    op.create_index('idx_users_last_login', 'users', ['last_login'], unique=False)
    op.create_index(op.f('ix_users_is_active'), 'users', ['is_active'], unique=False)
    op.create_index(op.f('ix_users_is_deleted'), 'users', ['is_deleted'], unique=False)
    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_users_is_deleted'), table_name='users')
    op.drop_index(op.f('ix_users_is_active'), table_name='users')
    op.drop_index('idx_users_last_login', table_name='users')
    op.drop_index('idx_users_is_deleted_username', table_name='users')
    op.drop_index('idx_users_is_deleted_is_active', table_name='users')
    op.drop_index('idx_users_is_deleted_email', table_name='users')
    op.drop_index('idx_user_roles_user_id', table_name='user_roles')
    op.drop_index('idx_user_roles_role_id', table_name='user_roles')
    op.drop_index(op.f('ix_roles_is_deleted'), table_name='roles')
    op.drop_index(op.f('ix_roles_is_active'), table_name='roles')
    op.drop_index('idx_roles_is_deleted_name', table_name='roles')
    op.drop_index('idx_roles_is_deleted_is_active', table_name='roles')
    op.drop_index('idx_role_permissions_role_id', table_name='role_permissions')
    op.drop_index('idx_role_permissions_permission_id', table_name='role_permissions')
    op.drop_index(op.f('ix_permissions_resource'), table_name='permissions')
    op.drop_index(op.f('ix_permissions_is_deleted'), table_name='permissions')
    op.drop_index(op.f('ix_permissions_action'), table_name='permissions')
    op.drop_index('idx_permissions_resource_action', table_name='permissions')
    op.drop_index('idx_permissions_resource', table_name='permissions')
    op.drop_index('idx_permissions_is_deleted_name', table_name='permissions')
    op.drop_index('idx_permissions_is_deleted_code', table_name='permissions')
    op.drop_index(op.f('ix_audit_logs_user_id'), table_name='audit_logs')
    op.drop_index(op.f('ix_audit_logs_status'), table_name='audit_logs')
    op.drop_index(op.f('ix_audit_logs_resource'), table_name='audit_logs')
    op.drop_index(op.f('ix_audit_logs_is_deleted'), table_name='audit_logs')
    op.drop_index(op.f('ix_audit_logs_action'), table_name='audit_logs')
    op.drop_index('idx_audit_logs_user_id_created_at', table_name='audit_logs')
    op.drop_index('idx_audit_logs_status_created_at', table_name='audit_logs')
    op.drop_index('idx_audit_logs_resource_resource_id', table_name='audit_logs')
    op.drop_index('idx_audit_logs_is_deleted', table_name='audit_logs')
    op.drop_index('idx_audit_logs_ip_address', table_name='audit_logs')
    op.drop_index('idx_audit_logs_created_at', table_name='audit_logs')
    op.drop_index('idx_audit_logs_action_created_at', table_name='audit_logs')
    # ### end Alembic commands ###
